package com.ruoyi.controller;

import com.ruoyi.common.Result;
import com.ruoyi.entity.DecorationKeyword;
import com.ruoyi.service.DecorationKeywordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 装饰画关键词关联控制器
 * 处理装饰画与关键词关联的HTTP请求
 *
 * @author ruoyi
 */
@Api(tags = "装饰画关键词关联管理接口")
@RestController
@RequestMapping("/api/decoration/keyword")
public class DecorationKeywordController {
    
    @Autowired
    private DecorationKeywordService decorationKeywordService;
    
    /**
     * 获取装饰画关联的关键词列表
     *
     * @param decorationId 装饰画ID
     * @return 关键词关联列表
     */
    @ApiOperation("获取装饰画关联的关键词列表")
    @GetMapping("/list/{decorationId}")
    public Result<List<DecorationKeyword>> listKeywordsByDecorationId(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId) {
        List<DecorationKeyword> keywords = decorationKeywordService.listKeywordsByDecorationId(decorationId);
        return Result.success(keywords);
    }
    
    /**
     * 为装饰画添加关键词
     *
     * @param decorationId 装饰画ID
     * @param keywordId 关键词ID
     * @return 添加结果
     */
    @ApiOperation("为装饰画添加关键词")
    @PostMapping("/{decorationId}/{keywordId}")
    public Result<Boolean> addKeyword(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("关键词ID") @PathVariable Integer keywordId) {
        boolean success = decorationKeywordService.addKeyword(decorationId, keywordId);
        return Result.success(success);
    }
    
    /**
     * 移除装饰画的关键词
     *
     * @param decorationId 装饰画ID
     * @param keywordId 关键词ID
     * @return 移除结果
     */
    @ApiOperation("移除装饰画的关键词")
    @DeleteMapping("/{decorationId}/{keywordId}")
    public Result<Boolean> removeKeyword(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("关键词ID") @PathVariable Integer keywordId) {
        boolean success = decorationKeywordService.removeKeyword(decorationId, keywordId);
        return Result.success(success);
    }
    
    /**
     * 批量添加装饰画关键词
     *
     * @param decorationId 装饰画ID
     * @param keywordIds 关键词ID列表
     * @return 添加结果
     */
    @ApiOperation("批量添加装饰画关键词")
    @PostMapping("/{decorationId}/batch")
    public Result<Boolean> batchAddKeywords(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("关键词ID列表") @RequestBody List<Integer> keywordIds) {
        boolean success = decorationKeywordService.batchAddKeywords(decorationId, keywordIds);
        return Result.success(success);
    }
    
    /**
     * 批量移除装饰画关键词
     *
     * @param decorationId 装饰画ID
     * @param keywordIds 关键词ID列表
     * @return 移除结果
     */
    @ApiOperation("批量移除装饰画关键词")
    @DeleteMapping("/{decorationId}/batch")
    public Result<Boolean> batchRemoveKeywords(
            @ApiParam("装饰画ID") @PathVariable Integer decorationId,
            @ApiParam("关键词ID列表") @RequestBody List<Integer> keywordIds) {
        boolean success = decorationKeywordService.batchRemoveKeywords(decorationId, keywordIds);
        return Result.success(success);
    }
} 